package com.example.jsruntimedemo.js.view;

import android.content.Context;
import android.widget.LinearLayout;

import com.eclipsesource.v8.V8Object;
import com.example.jsruntimedemo.js.dom.DomElement;
import com.example.jsruntimedemo.js.dom.DomFactory;
import com.example.jsruntimedemo.js.dom.DomVerticalLayout;

public class VerticalLayoutJsView extends JsView<LinearLayout, DomVerticalLayout>{
    @Override
    public String getType() {
        return "verticalLayout";
    }

    @Override
    public LinearLayout createViewInternal(Context context) {
        LinearLayout layout=new LinearLayout(context);
        layout.setOrientation(LinearLayout.VERTICAL);
        for (int i=0;i<mDomElement.children.length();i++){
            DomElement domElement= DomFactory.create((V8Object) mDomElement.children.get(i));
            if (domElement==null){
                continue;
            }
            JsView jsView=JsViewFactory.create(domElement);
            layout.addView(jsView.createView(context));
        }
        return layout;
    }
}
